'2 command buttons are required
'one common dialog control
'one inet control

Dim net As Inet
Dim flag As Boolean
Dim State As Integer
Dim AccessType As String

=====================================

Private Sub cmdbrowse_Click()
CommonDialog1.Filter = "All files(*.*)|*.*|picture files(*.jpg)|*.jpg"
CommonDialog1.FilterIndex = 2
CommonDialog1.ShowOpen
Text2.Text = CommonDialog1.fileName
End Sub

private Sub cmdupload_Click()
Dim localfile As String
        Dim remoteFile As String
        Dim fileName As String
        Dim filepath, fileid As String
        Dim seperatorPos, s1 As Integer

        
        ChDir App.Path   ' for setting the cwd.
        'Open Text1.Text For Input As #2
         localfile = Text2.Text
         'Do While Not EOF(2)
            'Line Input #2, localfile
                seperatorPos = InStrRev(localfile, "\", -1, vbTextCompare)
                fileName = Right(localfile, Len(localfile) - seperatorPos)
                s1 = InStrRev(localfile, "\", -1, vbTextCompare)
                fileid = Right(localfile, Len(localfile) - s1)
                MsgBox fileid
                'filepath = fReturnFilePath(fileName, App.Path)
                'intDataNum = intDataNum + 1 '... this may be used to mention the successful uploads
                remoteFile = "remote directory name where to store" & fileName
                Dim str As String
                'Text1.Text = localfile
                'str = " " & localFile & " " & remoteFile
                'Text1.Text = str
                Inet1.Execute , "PUT """ & localfile & """ """ & remoteFile & """"
                'Inet1.Execute , "PUT " & localFile & " " & remoteFile & " " '.. Successful upload bulk commented due to updations
                'Inet1.Execute , "PUT ""c:\hellmsn.exe"" ""html/snjoshiNew/hellmsn.exe"""  ' for Single file upload
                Me.lblRESPONSE.Caption = " Response : " & Inet1.ResponseInfo & " Response Code " & Inet1.ResponseCode
                Me.lblRESPONSE.Caption = "Application File Successfully Purged." & vbExclamation
                MsgBox "Application File Successfully Purged.", vbExclamation
end sub


Private Sub Inet1_StateChanged(ByVal State As Integer)

' Purpose: This is to capture the FTP state change i.e exa: once 'FTP is getting connected.

  
    On Error Resume Next
    Dim vtData As Variant
    Select Case State
           Case icNone
           Case icResolvingHost: Me.lblRESPONSE.Caption = "Resolving Host"
           Case icHostResolved: Me.lblRESPONSE.Caption = "Host Resolved"
           Case icConnecting: Me.lblRESPONSE.Caption = "Connecting..."
           Case icConnected: Me.lblRESPONSE.Caption = "Connected"
           Case icResponseReceived: Me.lblRESPONSE.Caption = "Transferring File..."
           Case icDisconnecting: Me.lblRESPONSE.Caption = "Disconnecting..."
           Case icDisconnected: Me.lblRESPONSE.Caption = "Disconnected"
           Case icError: MsgBox "Error:" & Inet1.ResponseCode & " " & Inet1.ResponseInfo
           Case icResponseCompleted:  Me.lblRESPONSE.Caption = "Process Complete."
     End Select
      
         Me.lblRESPONSE.Refresh
        
      Err.Clear
      
End Sub


Private Sub Command1_Click()
       On Error GoTo FTPError
'
' Dated :
' This id to connect test the Internet connection to specified remote host
'
        Inet1.url = "ftp://Server-name"
          Inet1.UserName = " "
          Inet1.Password = " "
          Inet1.Execute , "", "POST", ""
FTPError:
            Select Case Err.Number
            Case 35754
                 'MsgBox Err.Description
                 Form1.Label2.Caption = Err.Description
            Case Default
                 'MsgBox "Connected Successfully."
                 Form1.Label2.Caption = "  Connected Successfuly.  "
            End Select
End Sub


Private Sub inetconnect()

' Function Name : Initialising the Inet Control here.
' Purpose       : To inititalise the Inet Data Transfer Control
' Author        : Chetan v. Kokil


  Inet1.url = "ftp://server-name/directory_name"
  Inet1.Proxy = "http://server-name/directory_name"
  Inet1.UserName = " "
  Inet1.Password = " "
  Inet1.RequestTimeout = 60
  Inet1.AccessType = icDirect
  Inet1.Protocol = icFTP
  Inet1.RemotePort = 21

End Sub